home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / c01lab5.zip / SPACEMON / SENSORS.SRC < prev    next >
Text File  |  1992-03-17  |  6KB  |  152 lines

  1. -- **************************************************
  2. -- *                                                *
  3. -- *  Spacecraft_Sensor_Interface                   *  SPEC
  4. -- *                                                *
  5. -- **************************************************
  6. package Spacecraft_Sensor_Interface is
  7.  
  8.   type SPACECRAFT_SECTION is (BRIDGE, AUXILIARY_BRIDGE,
  9.                               CREW_QUARTERS, GALLEY,
  10.                               LAB1, LAB2, LAB3,
  11.                               AIRLOCK1, AIRLOCK2,
  12.                               EXPERIMENT_BAY);
  13.  
  14.   type PRESSURE is new FLOAT
  15.       range 0.0 .. 400.0;          -- psi
  16.   subtype TOLERATED_PRESSURE is PRESSURE
  17.       range 20.0 .. 80.0;
  18.  
  19.   type TEMPERATURE is new FLOAT
  20.       range -400.0 .. 2_000.0;     -- Fahrenheit
  21.   subtype TOLERATED_TEMPERATURE is TEMPERATURE
  22.       range -20.0 .. 120.0;
  23.  
  24.   type RADIATION_LEVEL is new FLOAT
  25.       range 0.0 .. 8_000.0;        -- Roentgens
  26.   subtype TOLERATED_RADIATION_LEVEL is RADIATION_LEVEL
  27.       range 0.0 .. 400.0;
  28.  
  29.   -- .................................................
  30.   -- .                                               .
  31.   -- .  Spacecraft_Sensor_Interface.Sensed_Value     .  SPEC
  32.   -- .                                               .
  33.   -- .................................................
  34.   function Sensed_Value
  35.       (Location : in SPACECRAFT_SECTION) return PRESSURE;
  36.   function Sensed_Value
  37.       (Location : in SPACECRAFT_SECTION) return TEMPERATURE;
  38.   function Sensed_Value
  39.       (Location : in SPACECRAFT_SECTION) return RADIATION_LEVEL;
  40.   --| Purpose
  41.   --|    Return sensor readings from different parts of the
  42.   --| spacecraft.
  43.   --|
  44.   --| Exceptions (none)
  45.   --| Notes
  46.   --|     If values exceed the limits set for the different
  47.   --| types, the corresponding maximum or minimum values are
  48.   --| returned.  Assume that sensor validation is performed
  49.   --| internally to these routines.
  50.   -- .................................................
  51.   -- .                                               .
  52.   -- .  Spacecraft_Sensor_Interface.Update           .  SPEC
  53.   -- .                                               .
  54.   -- .................................................
  55.   procedure Update;
  56.   --| Purpose
  57.   --|     Examine each sensor and update its status.  This
  58.   --| update includes sensor input validation.
  59.   --|
  60.   --| Exceptions (none)
  61.   --| Notes
  62.   --|     Update must be called before calling any of the
  63.   --| Sensed_Value routines.  Update checks all sensors, so
  64.   --| the scenario is to call Update and then call all the
  65.   --| permutations of the Sensed_Value routines before
  66.   --| calling Update again.
  67.  
  68. end Spacecraft_Sensor_Interface;
  69.  
  70. -- **************************************************
  71. -- *                                                *
  72. -- *  Spacecraft_Sensor_Interface                   *  BODY
  73. -- *                                                *
  74. -- **************************************************
  75. package body Spacecraft_Sensor_Interface is
  76.  
  77.   type PRESSURE_TABLE is array (NATURAL range <>) of PRESSURE;
  78.   type TEMPERATURE_TABLE is array (NATURAL range <>) of TEMPERATURE;
  79.   type RADIATION_TABLE is array (NATURAL range <>) of RADIATION_LEVEL;
  80.   type INDEX_VECTOR is array (SPACECRAFT_SECTION) of NATURAL;
  81.  
  82.   P_Index : INDEX_VECTOR :=
  83.     (5, 2, 1, 4, 3, 7, 6, 8, 9, 10);
  84.   T_Index : INDEX_VECTOR :=
  85.     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  86.   R_Index : INDEX_VECTOR :=
  87.     (10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
  88.  
  89.   P_Table : constant PRESSURE_TABLE :=
  90.     (32.5, 32.5, 32.5, 32.5, 50.0, 75.0, 80.0, 90.0, 110.0, 32.5, 32.5,
  91.      20.0, 10.0, 30.0, 32.5, 32.5, 40.0, 250.0, 32.5);
  92.   T_Table : constant TEMPERATURE_TABLE :=
  93.     (70.0, 70.0, 71.0, 75.0, 80.0, 100.0, 120.0, 140.0, 130.0, 140.0,
  94.      135.0, 130.0, 125.0, 120.0, 100.0, 80.0, 75.0, 73.0, 70.0);
  95.   R_Table : constant RADIATION_TABLE :=
  96.     (10.0, 20.0, 15.0, 20.0, 50.0, 100.0, 400.0, 500.0, 600.0, 700.0,
  97.      1000.0, 50.0, 30.0, 20.0, 10.0, 5.0, 5.0, 8.0, 10.0);
  98.  
  99.   -- .................................................
  100.   -- .                                               .
  101.   -- .  Spacecraft_Sensor_Interface.Sensed_Value     .  BODY
  102.   -- .                                               .
  103.   -- .................................................
  104.   function Sensed_Value
  105.       (Location : in SPACECRAFT_SECTION) return PRESSURE is
  106.   begin
  107.     return P_Table(P_Index(Location));
  108.   end Sensed_Value;
  109.  
  110.   function Sensed_Value
  111.       (Location : in SPACECRAFT_SECTION) return TEMPERATURE is
  112.   begin
  113.     return T_Table(T_Index(Location));
  114.   end Sensed_Value;
  115.  
  116.   function Sensed_Value
  117.       (Location : in SPACECRAFT_SECTION) return RADIATION_LEVEL is
  118.   begin
  119.     return R_Table(R_Index(Location));
  120.   end Sensed_Value;
  121.  
  122.   -- .................................................
  123.   -- .                                               .
  124.   -- .  Spacecraft_Sensor_Interface.Update           .  SPEC
  125.   -- .                                               .
  126.   -- .................................................
  127.   procedure Update is
  128.  
  129.   begin
  130.  
  131.     for Location in SPACECRAFT_SECTION loop
  132.       P_Index(Location) := P_Index(Location) + 1;
  133.       if P_Index(Location) > P_Table'LAST then
  134.         P_Index(Location) := 0;
  135.       end if;
  136.  
  137.       T_Index(Location) := T_Index(Location) + 1;
  138.       if T_Index(Location) > T_Table'LAST then
  139.         T_Index(Location) := 0;
  140.       end if;
  141.  
  142.       R_Index(Location) := R_Index(Location) + 1;
  143.       if R_Index(Location) > R_Table'LAST then
  144.         R_Index(Location) := 0;
  145.       end if;
  146.     end loop;
  147.   end Update;
  148.  
  149. end Spacecraft_Sensor_Interface;
  150.  
  151.  
  152.